<template>
  <el-header class="custom-header">
    <div class="header-content">
      <div class="logo-container">
        <span class="logo">膳食管理系统</span>
      </div>
      <div class="user-dropdown">
        <el-dropdown>
          <span class="el-dropdown-link">
            <el-avatar :size="40" src="https://avatars.githubusercontent.com/u/1?v=4" />
            <span style="margin-left: 10px;">管理员</span>
          </span>
          <template #dropdown>
            <el-dropdown-menu>
              <el-dropdown-item>个人中心</el-dropdown-item>
              <el-dropdown-item @click="handleLogout">退出登录</el-dropdown-item>
            </el-dropdown-menu>
          </template>
        </el-dropdown>
      </div>
    </div>
  </el-header>
</template>

<script setup>
import { useRouter } from 'vue-router';

const router = useRouter();

const handleLogout = () => {
  localStorage.removeItem('isLoggedIn');
  router.push('/login');
};
</script>

<style scoped>
.custom-header {
  background-color: #304156; /* 更改背景颜色为深色 */
  box-shadow: 0 2px 4px rgba(0, 0, 0, 0.2); /* 增加阴影 */
  height: 60px; /* 设置固定高度 */
  display: flex;
  align-items: center;
  position: fixed; /* 固定在顶部 */
  top: 0;
  left: 0;
  right: 0;
  z-index: 1000; /* 确保在最上层 */
}

.header-content {
  display: flex;
  align-items: center;
  justify-content: space-between;
  width: 100%;
  padding: 0 20px;
}

.logo-container {
  color: #fff; /* 文字颜色为白色 */
}

.logo {
  font-size: 24px; /* 增大字体大小 */
  font-weight: bold;
}

.user-dropdown .el-dropdown-link {
  display: flex;
  align-items: center;
  cursor: pointer;
  color: #fff; /* 文字颜色为白色 */
}

.user-dropdown .el-dropdown-link:hover {
  color: #ffd04b; /* 悬停时颜色 */
}
</style>